package com.lsu.app.mapper;

import com.lsu.app.bean.Praise;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

/**
 *
 * @description 针对表【praise(点赞表)】的数据库操作Mapper
 * @Date 2023-10-27 11:01:29
 * @author hjj
 */
@Mapper
public interface PraiseMapper extends BaseMapper<Praise> {

    @Select("select * from praise where user_id = #{userId} and type = #{type} and target_id= #{targetId}")
    Praise getOneByUserIdAndTypeAndTargetId(@Param("userId") Integer userId, @Param("type") Integer type, @Param("targetId") Integer targetId);//根据用户id、类型、目的id获取点赞信息
    @Select("select count(*) from praise where type=#{type} and target_id = #{targetId}")
    Integer getNumByTypeAndTargetId(@Param("type") Integer type,@Param("targetId") Integer targetId);
    @Select("select count(*) from praise where user_id=#{userId} and target_id=#{targetId} and type=#{type}")
    Integer getSelfLike(@Param("userId") Integer userId,@Param("targetId") Integer targetId,@Param("type")Integer type);//查询自己是否点赞
}


